package com.product.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.product.app.mapper.ProductMapper;
import com.product.app.service.ProductService;
import com.tamll.bean.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductMapper productMapper;

    @Override
    public Page<Product> getList(Integer pageNumber, Integer num) {
        Page<Product> productPage=new Page<>(pageNumber,num);
        QueryWrapper<Product> queryWrapper=new QueryWrapper<>();
        Page<Product> productIPage = productMapper.selectPage(productPage, queryWrapper);
        System.out.println("总页数:"+productIPage.getPages());
        System.out.println("总记录数:"+productIPage.getTotal());
        return productIPage;
    }

    @Override
    public Product get(Integer productId) {
        QueryWrapper<Product> wrapper=new QueryWrapper<>();
        wrapper.eq("productId",productId);
        Product product = productMapper.selectOne(wrapper);
        return product;
    }

}
